package com.ctshk.rpc.finance.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.finance.base.CustomBaseMapper;
import com.ctshk.rpc.finance.dto.onaccount.OnAccountUsageCountDTO;
import com.ctshk.rpc.finance.entity.FinanceOffAccountApplyDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 销账对应收退款记录 Mapper 接口
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-03-31
 */
public interface FinanceOffAccountApplyDetailMapper extends CustomBaseMapper<FinanceOffAccountApplyDetail> {

    /**
     * 已收金额
     * @param customerId
     * @return
     */
    @Select("SELECT a.currency_id,a.currency_name,a.exchange_rate,a.total_amount\n" +
            "FROM t_finance_off_account_apply_detail a\n" +
            "LEFT JOIN t_finance_on_account b ON a.on_account_id = b.id\n" +
            "WHERE b.account_id = #{account_id} AND a.is_deleted = 0\n" +
            "GROUP BY a.currency_id\n")
    List<OnAccountUsageCountDTO> selectSumByAccount(@Param("account_id") Long customerId);
}
